<?php

namespace app\model;

use think\Model;

class SystemChina extends Model
{
    /**
     * 省市区表
     */

    /**
     * 获取编码对应名称
     * @param $code
     * @return mixed
     */
    public function getCodeCityNameModel($code)
    {
        return $this->where (['code_id'=>$code])->value ('city_name');
    }

    /**
     * 通过省市区名称查询code
     * @param $name
     * @return mixed
     */
    public function getNameCodeModel($name)
    {
        return $this->where (['city_name'=>$name])->value ('code_id');

    }

    /**
     * 获取拼接省市区
     * @param $provinceCode
     * @param $cityCode
     * @param $areaCode
     * @return string
     */
    public function getAreaDataModel($provinceCode,$cityCode,$areaCode): string
    {
        $provinceName = $this->where (['code_id'=>$provinceCode])->value ('city_name');
        $cityName = $this->where (['code_id'=>$cityCode])->value ('city_name');
        $areaName = $this->where (['code_id'=>$areaCode])->value ('city_name');

        return $provinceName.$cityName.$areaName;
    }
}